package cn.cvs.service.impl;

import cn.cvs.dao.UHistoryMapper;
import cn.cvs.pojo.UHistory;
import cn.cvs.service.UHistoryService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class UHistoryServiceImpl implements UHistoryService {
    @Resource
    private UHistoryMapper uHistoryMapper;
    @Override
    public UHistory loginUHistory(String phone) {
        UHistory uHistory = uHistoryMapper.getUHistoryByPhone(phone);

        return uHistory;
    }

    @Override
    public int addUHistory(UHistory uHistory) {

        Date firstDate=new Date();
        uHistory.setFirstDate(firstDate);
        return uHistoryMapper.addUHistory(uHistory);
    }

    @Override
    public List<UHistory> getUHistoryList(String firstDate, String phone) {
        return uHistoryMapper.getUHistoryList(firstDate,phone);
    }

    @Override
    public int deleteByUserId(Integer userId) {
        return uHistoryMapper.deleteByUserId(userId);
    }

    public static void main(String[] args) {
       /* ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext-mybatis.xml");
        UHistoryService uHistoryService = context.getBean("uHistoryService", UHistoryService.class);
        List<UHistory> uHistoryList = uHistoryService.getUHistoryListByPhone("");
        System.out.println(uHistoryList);*/

    }
}
